package love.yuanmengrobot.attendancesystem.dao;
/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/6/22 10:09
 */

import love.yuanmengrobot.attendancesystem.dao.SQL.SqlString;
import love.yuanmengrobot.attendancesystem.entity.Member;
import love.yuanmengrobot.attendancesystem.util.JdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

public class ClazzMemberDao {


    public ArrayList<Member>  qureyClazzMemberById(String clazzid) {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtil.getConnection();
            stmt = conn.createStatement();
            rs = stmt.executeQuery(SqlString.selectClazzMember(clazzid));
            ArrayList<Member> list = new ArrayList<Member>();
            while (rs.next()) {
                Member member = new Member();
                member.setLoginid(rs.getString("loginid"));
                member.setName(rs.getString("name"));
                member.setPermission(rs.getString("permission"));
                list.add(member);
            }
            if(list.size()>0){
                return list;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {//回收资源
            JdbcUtil.close(rs, stmt, conn);
        }
        return null;
    }

}
